<?php
namespace Admin\Controller;
use Think\Controller;
use Think\Auth;//加载认证权限类库

class BaseController extends Controller {

    public function _initialize(){
        //无session跳到登录页面
        $admin = session('midiadmin');
        if(empty($admin)){
            $this->redirect('Login/index');
            exit();
        }

        //权限认证
        if ($admin['rules'] == '*') {
            return true;
        }
        $auth = new Auth();
        if(!$auth->check(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME,$admin['admin_id'])){

            $this->error('您没有权限进行此操作');
        }
    }


}